﻿// JavaScript Document

function btnLogin(){
	if($("cLogin").value == "" || $("cLogin").value.trim() == "") {
		$("userNameMsg").innerHTML = "用户名不能为空!";
		$("userNameMsg").style.display = "";
		$("userNameMsg").className="inputCheck_waring";
		$("cLogin").focus();
		return;
	}
	
	if($("cLoginpass").value == "" || $("cLoginpass").value.trim() == "") {
		$("userPassMsg").innerHTML = "密码不能为空!";
		$("userPassMsg").style.display = "";
		$("userPassMsg").className="inputCheck_waring";
		$("cLoginpass").focus();
		return;
	}
	
	if($("cYzm").value == "" || $("cYzm").value.trim() == "") {
		$("userYzmMsg").innerHTML = "请输入验证码!<br>";
		$("userYzmMsg").style.display = "";
		$("userYzmMsg").className="inputCheck_waring";
		$("cYzm").focus();
		return;
	}
	var gcLogin = new AjaxProxy();
	gcLogin.addParm("cLogin",$("cLogin").value);
	gcLogin.addParm("cPass",$("cLoginpass").value);
	gcLogin.addParm("cYzm",$("cYzm").value);
	gcLogin.invoke("login.userLogin",false);
	var flag = gcLogin.getString("PN_RET");
	if(flag != 0){
		$("imgYzm").src = "/checkCode?key="+new Date().getUTCMilliseconds();
		if(flag == 3){
			$("userYzmMsg").innerHTML = gcLogin.getString("PC_MSG")+"<BR>";
			$("userYzmMsg").style.display = "";
			$("userYzmMsg").className="inputCheck_waring";
		}else{
			alert(gcLogin.getString("PC_MSG"));
		}
	}else{
		//alert(gcLogin.getString("PC_ZT"));
		window.location.replace("/core");
	}
}

function checkUserName(obj){
	if(obj.value == "" || obj.value.trim() == "") {
		$("userNameMsg").innerHTML = "用户名不能为空!";
		$("userNameMsg").style.display = "";
		$("userNameMsg").className="inputCheck_waring";
	}else{
		$("userNameMsg").style.display = "none";
	}
}

function checkUserPass(obj){
	if(obj.value == "" || obj.value.trim() == "") {
		$("userPassMsg").innerHTML = "密码不能为空!";
		$("userPassMsg").style.display = "";
		$("userPassMsg").className="inputCheck_waring";
	}else{
		$("userPassMsg").style.display = "none";
	}
}

function checkYzm(obj){
	if(obj.value == "" || obj.value.trim() == "") {
		$("userYzmMsg").innerHTML = "请输入验证码!<br>";
		$("userYzmMsg").style.display = "";
		$("userYzmMsg").className="inputCheck_waring";
	}else{
		$("userYzmMsg").style.display = "none";
	}
}

function $(){
	return document.getElementById(arguments[0]);
}

String.prototype.trim = function() { 
	return this.replace(/(^\s*)|(\s*$)/g, "");
} 